<?php
// Check already session_start
$session_id = session_id();
if(empty($session_id )){
	session_start();
}

define('AUTHENTICATE_URL','http://50.0.150.21/CyberGatekeeper/CGSAuth/authuser.php');
define('GET_URL','http://50.0.150.20:9080/getrfad.php');
define('POST_URL','http://50.0.150.20:9080/putadr.php');
$username = 'nga';//'DOMAIN\USERNAME';
$password = 'nga';//'PASSWORD';
include_once 'main_helper.php';

if(empty($no_check_session)){
	if(empty($_SESSION['cgate_authenticated'])){
		$response = do_authenticate(AUTHENTICATE_URL,$username,$password);
		$response = strtolower($response);
		//pr('Login - $response:'.$response,1);
		if(strpos($response,'authentication successful') !== false){
			$_SESSION['cgate_authenticated'] = true;
			//pr('cgate_authenticated',1);
		} else {
			exit();
		}
	} else {
		//pr('Already cgate_authenticated',1);
		// NOW, ALWAYS AUTHENTICATE
		$response = do_authenticate(AUTHENTICATE_URL,$username,$password);
	}
}
